package com.guan.ordering_sys.generator.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.guan.ordering_sys.common.PageResult;
import com.guan.ordering_sys.common.ResultApi;
import com.guan.ordering_sys.generator.service.CallServiceService;
import com.guan.ordering_sys.vo.CallServiceVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 韩思琪
 * @since 2021-06-18
 */
@Api(tags = "呼叫服务控制器")
@RestController
@RequestMapping("/api/call-service")
public class CallServiceController {

    @Autowired
    CallServiceService callServiceService;

    @ApiOperation(value ="服务信息列表")
    @PostMapping("/callServiceList")
    public ResultApi callServiceList(
            @ApiParam("当前页") @RequestParam(required = true) int pageNum,
            @ApiParam("页面大小") @RequestParam(required = true) int pageSize){

        Page<CallServiceVo> callServiceVoPage = new Page<>();
        callServiceVoPage.setCurrent(pageNum);
        callServiceVoPage.setSize(pageSize);

        IPage<CallServiceVo> callServicesVoIPage = callServiceService.callServiceList(callServiceVoPage);
        PageResult<CallServiceVo> servicesVoPageResult = new PageResult<>(callServicesVoIPage.getRecords().size(), callServicesVoIPage.getRecords());
        return ResultApi.success(servicesVoPageResult);
    }

}

